package com.ywyself.plugin.spider;

import com.sun.istack.internal.NotNull;

import java.io.IOException;

public abstract class Spider {
    private static Spider spider;

    public static Spider getSpider(String className) {
        try {
            Class<?> c = Class.forName("com.ywyself.plugin.spider.impl." + className);
            return  (Spider) c.newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 列出章节
     *
     * @param url
     * @return
     */
    public abstract java.util.List<String[]> listCate(@NotNull String url);

    /**
     * 读取章节内容
     *
     * @param url
     * @return {章节名称, 章节内容}
     */
    public abstract String[] getContent(@NotNull String url);
}
